using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using BLL;
using BLL.Impl;

namespace WebUI.Admin.Role
{
    public partial class Role_List : System.Web.UI.Page
    {
        private IAdminManager adminManager;
        protected void Page_Load(object sender, EventArgs e)
        {
            adminManager = BLLFactory.CreateAdminManager();
            if (!IsPostBack)
            {
                Display();
            }
        }

        private void Display()
        {
            this.grvRoleList.DataSource = adminManager.ListRole();
            this.grvRoleList.DataKeyNames = new string[] { "RoleSN"};
            this.grvRoleList.DataBind();
        }

        protected void grvRoleList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Model.Role role = new Model.Role();
            role.RoleSN = Int32.Parse(this.grvRoleList.DataKeys[e.RowIndex].Value.ToString());
            adminManager.DelectRole(role);
            Display();
        }

        protected void grvRoleList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.grvRoleList.PageIndex = e.NewPageIndex;
            Display();
        }

    }
}
